package com.example.happiness.service.admin.Impl;

import com.example.happiness.mapper.OrderMapper;
import com.example.happiness.pojo.generalDTO.OrderStateDTO;
import com.example.happiness.pojo.admindto.OrdersPageDto;
import com.example.happiness.pojo.adminvo.AdminOrderPageVO;
import com.example.happiness.pojo.adminvo.PageResult;
import com.example.happiness.service.admin.AdminOrderService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminOrderServiceImpl implements AdminOrderService {

    @Autowired
    OrderMapper orderMapper;

    public PageResult pageQuery(OrdersPageDto ordersPageDto) {
        PageHelper.startPage(ordersPageDto.getPage(),ordersPageDto.getPageSize());
        //下一条sql进行分页，自动加入limit关键字分页
        Page<AdminOrderPageVO> page = orderMapper.pageQuery(ordersPageDto);
        return new PageResult(page.getTotal(), page.getResult());
    }

    public void updataOrderState(OrderStateDTO orderStateDTO) {
        orderMapper.updataOrderState(orderStateDTO);
    }
}
